home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 November / EnigmA AMIGA RUN 02 (1995)(G.R. Edizioni)(IT)[!][issue 1995-11][Skylink CD].iso / earcd / util / text / frexxedv.lha / FrexxEdpatch / fpl / FillText.FPL < prev    next >
Text File  |  1995-09-12  |  2KB  |  70 lines

  1. // $Id: FillText.FPL 1.1 1995/09/12 15:30:48 jskov Exp $
  2. // $VER: FillText.FPL 1.0 (12.09.95) © Jesper Skov
  3.  
  4. //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» fillText ««
  5. export void fillText()
  6. {
  7.   if (ReadInfo("line_length")==1){
  8.     ReturnStatus("Place cursor in a paragraph!");
  9.     return;
  10.   }
  11.  
  12.   Visible(0);
  13.  
  14.   // Find topmost line
  15.   while((ReadInfo("line_length")>1) && ReadInfo("line")>1)
  16.     CursorUp();
  17.   if(ReadInfo("line")!=1)
  18.     CursorDown();
  19.  
  20.   CursorDown();Home();
  21.  
  22.   // Put all lines in paragraph on same line
  23.   while(ReadInfo("line_length")>1){
  24.     Backspace();Output(" ");
  25.     CursorDown();Home();
  26.   }
  27.   CursorUp();
  28.  
  29.   // Delete leading spaces
  30.   while(Isspace(GetChar()))
  31.     Delete();
  32.  
  33.   BlockMark(0);
  34.   BlockMarkLine(-1);
  35.  
  36.   Replace(1,"\t"," ","=bf+");                // replace tabs with space
  37.   Home();
  38.   Replace(1,"  +"," ","=bfw+");                // replace multiple spaces with space
  39.   Home();
  40.   if(ReadInfo("fill_text_US")){                // if wanted, set US double space
  41.     Replace(1,". ",".  ","=bf+");
  42.     Home();
  43.   }
  44.  
  45.   BlockMark(0);
  46.  
  47.   // Now split line up in valid sized single lines
  48.   while(GotoLine(ReadInfo("line"),ReadInfo("wall_right"))){
  49.     // If a word is crossing the wall_right, go left of it.
  50.     if(!Isspace(GetChar(ReadInfo("byte_position")-1))){
  51.       CursorLeftWord();
  52.       if (ReadInfo("column")==1)            // very long word!
  53.         CursorRightWord();                    // simply go back!
  54.     }
  55.     Backspace();
  56.     if (Isspace(GetChar(ReadInfo("byte_position")-1)))
  57.       Backspace();                            // clear extra for US .
  58.     Output("\n");
  59.   }     
  60.  
  61.   // Delete last space there may be after a .
  62.   if(Isspace(GetChar(ReadInfo("byte_position")-1)))
  63.     Backspace();
  64.  
  65.   Visible(1);RedrawScreen();
  66. }
  67.  
  68. //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» Info vars ««
  69. ConstructInfo("fill_text_US","","","WBG(display)","",0,1,0);
  70.